package com.example.a_base

/**
@author whd
@date 2023/10/13 09:59:46
 */
val PI = 3.14
var x = 0
fun main() {
 /* println("hello,world")
  for (i in 0..100) {
    incrementX()
    println("x = ${x}")
  }
  val sum = sum(4, 5)
  println("sum = ${sum}")*/
 /* val items = listOf("apple", "banana", "kiwifruit")
  for ((index, s) in items.withIndex()) {
    println("index = ${index}")
    println("s = ${s}")

  }*/
  //val describe = describe("Hello")
 // println("describe = ${describe}")
  println(exit(23))
  println(exit(43))
}
fun sum(x: Int, y: Int): Int {
  return x+y
}

fun incrementX() {
   x+=1
}

/*
* 这里的when类似与Java中的swith  case 语法如下，根据需求变化*/
fun describe(obj: Any): String =
  when (obj) {
    1          -> "One"
    "Hello"    -> "Greeting"
    is Long    -> "Long"
    !is String -> "Not a string"
    else       -> "Unknown"
  }
fun exit(num:Int):Boolean{
  return num in 34..50
}
